SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE [dbo].gspComment_SEARCH
(
@commentId int = null,
@parentCommentId int = null,
@productId int = null,
@content nvarchar(4000) = null,
@createdDate datetime = null,
@lastModifiedDate datetime = null,
@isDeleted bit = null
)
AS

SELECT
  *
FROM
  [dbo].[Comment]
WHERE
  (@commentId IS NULL OR [CommentId] = @commentId)
AND
  (@parentCommentId IS NULL OR [ParentCommentId] = @parentCommentId)
AND
  (@productId IS NULL OR [ProductId] = @productId)
AND
  (@content IS NULL OR @content = '' OR [Content] LIKE @content + '%')
AND
  (@createdDate IS NULL OR [CreatedDate] = @createdDate)
AND
  (@lastModifiedDate IS NULL OR [LastModifiedDate] = @lastModifiedDate)
AND
  (@isDeleted IS NULL OR [IsDeleted] = @isDeleted)


GO
